<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/3/10
  Time: 15:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
    String rootPath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()+"/";
%>
<html>
<head>
    <title>Title</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script src="/js/jquery/jquery-1.8.2.min.js"></script>
    <link href="../assets/css/dpl-min.css" rel="stylesheet" type="text/css" />
    <link href="../assets/css/bui-min.css" rel="stylesheet" type="text/css" />
    <link href="../assets/css/page-min.css" rel="stylesheet" type="text/css" />
    <script >
        $(document).ready(function(){
            $("#mytable input[type='checkbox']").change(function() {
                if ($(this).is(":checked")) {

                    this.value=1;
                }else {
                    alert("你取消选中了");
                    this.value=0;
                }
            });
        })


        function checkForm()
        {
            $("#mytable input[type='checkbox']").each(function () {
                if(!this.checked){
                    this.checked = true;
                }
            })
            return true;
        }

    </script>
</head>
<body>
<form action="${pageContext.request.contextPath }/user/testCheck.do" method="post">
    <table id="mytable">
        <tr><td>1</td>
            <td><input type="checkbox" value="0" name="userList[0].id"></td>
            <td><input type="checkbox" value="0" name="userList[0].userName"></td>
            <td><input type="checkbox" value="0" name="userList[0].password"></td>
        </tr>
        <tr><td>2</td>
            <td><input type="checkbox" value="0" name="userList[1].id"></td>
            <td><input type="checkbox" value="0" name="userList[1].userName"></td>
            <td><input type="checkbox" value="0" name="userList[1].password"></td>

        </tr>
        <tr><td>3</td>
            <td><input type="checkbox" value="0" name="userList[2].id"></td>
            <td><input type="checkbox" value="0" name="userList[2].userName"></td>
            <td><input type="checkbox" value="0" name="userList[2].password"></td>


        </tr>
        <tr><td>4</td>
            <td><input type="checkbox" value="0" name="userList[3].id"></td>
            <td><input type="checkbox" value="0" name="userList[3].userName"></td>
            <td><input type="checkbox" value="0" name="userList[3].password"></td>


        </tr>
    </table>
    <button type="submit" onclick="checkForm()"> 提交</button>
</form>
</body>
</html>
